/***************************************************************************
  A SymbolBrowser plugin for JuffEd editor.

  Copyright: 2010 Aleksander Sokoloff <asokol@mail.ru>


  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License.
  version 2 as published by the Free Software Foundation.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software Foundation,
  Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
***************************************************************************/

#include "katedocumentparser.h"
#include <ktexteditor/view.h>
#include <ktexteditor/cursor.h>
#include <QString>


/**********************************************************
 *
 **********************************************************/
KateDocumentParser::KateDocumentParser(SymbolBrowserView *view, KTextEditor::Document * parent)
: DocumentParser(view, parent)
{
    mKateDocument = parent;
}


/**********************************************************
 *
 **********************************************************/
KateDocumentParser::~KateDocumentParser()
{
}


/**********************************************************
 *
 **********************************************************/
Language KateDocumentParser::language() const
{
    QString syntaxStr = mKateDocument->mode();

    if (syntaxStr == "C++")         return LanguageCpp;
    if (syntaxStr == "C")           return LanguageC;
    if (syntaxStr == "C#")          return LanguageCsharp;
    if (syntaxStr == "Java")        return LanguageJava;
    if (syntaxStr == "Python")      return LanguagePython;
    if (syntaxStr == "Makefile")    return LanguageMakefile;

    if (syntaxStr == "")            return LanguageUnknown;

    //qDebug() << QString("Unknown syntax: '%1'").arg(syntaxStr);
    return LanguageUnknown;
}


/**********************************************************
 *
 **********************************************************/
void KateDocumentParser::getText(QString &text) const
{
    text = mKateDocument->text();
}


/**********************************************************
 *
 **********************************************************/
void KateDocumentParser::skipToLine(int line)
{
    KTextEditor::View *view = mKateDocument->activeView();
    if (view)
        view->setCursorPosition(KTextEditor::Cursor(line, 1000));
}
